package com.example.test.dialogfactory;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView.ViewHolder;
import com.google.android.flexbox.FlexDirection;
import com.google.android.flexbox.FlexWrap;
import com.google.android.flexbox.FlexboxLayoutManager;
import easier.recycler.BaseViewHolder;
import easier.recycler.MultiTypeAdapter;
import easier.recycler.TypeViewHolder;
import java.util.ArrayList;
import java.util.List;

public class MainActivity65 extends AppCompatActivity {

    private RecyclerView mRecycler;

    public static void start( Context context ) {

        Intent starter = new Intent( context, MainActivity65.class );
        context.startActivity( starter );
    }

    @Override
    protected void onCreate( Bundle savedInstanceState ) {

        super.onCreate( savedInstanceState );
        setContentView( R.layout.activity_main65 );
        initView();
    }

    private void initView() {

        mRecycler = (RecyclerView) findViewById( R.id.recycler );
        mRecycler.setLayoutManager( new FlexboxLayoutManager( this, FlexDirection.ROW, FlexWrap.WRAP ) );
        mRecycler.setAdapter( new MultiTypeAdapter( conver() ) );
    }

    private List< TypeViewHolder > conver() {

        List< TypeViewHolder > list = new ArrayList<>();
        for ( int i = 0; i < 20; i++ ) {
            list.add( build( i ) );
        }
        return list;
    }

    private TypeViewHolder build( int i ) {

        return new BaseViewHolder( R.layout.activity_main65_item ) {
            @Override
            protected void onBind( ViewHolder viewHolder, View root, int position, int type, List< Object > payloads ) {

                super.onBind( viewHolder, root, position, type, payloads );
            }
        };
    }
}